<?php

namespace App\Models\Teaching;

use App\Models\System\Dicitem;
use Illuminate\Database\Eloquent\Model;

class TeachingActivity extends Model
{
    protected $table = 'teaching_activity';
    protected $guarded = [];
    protected $appends = [
        'activity_type_name'
    ];

    public function live()
    {
        return $this->belongsTo(Live::class);
    }

    public function getActivityTypeNameAttribute(){
        $type = !empty($this->attributes['activity_type']) ? $this->attributes['activity_type'] : '';

        if($type){
            $dic = Dicitem::where('diccode', 'HDLB')->where("itemcode", $type)->first();
            if($dic) {
                $type = $dic->itemname;
            }
        }

        return $type;
    }
}
